(function(vc){
    vc.extends({
        propTypes: {
           emitChooseShopCommunity:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseShopCommunityInfo:{
                shopCommunitys:[],
                _currentShopCommunityName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseShopCommunity','openChooseShopCommunityModel',function(_param){
                $('#chooseShopCommunityModel').modal('show');
                $that._refreshChooseShopCommunityInfo();
                $that._loadAllShopCommunityInfo(1,10,'');
            });
        },
        methods:{
            _loadAllShopCommunityInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('shopCommunity.listShopCommunitys',
                             param,
                             function(json){
                                var _shopCommunityInfo = JSON.parse(json);
                                $that.chooseShopCommunityInfo.shopCommunitys = _shopCommunityInfo.shopCommunitys;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseShopCommunity:function(_shopCommunity){
                if(_shopCommunity.hasOwnProperty('name')){
                     _shopCommunity.shopCommunityName = _shopCommunity.name;
                }
                vc.emit($props.emitChooseShopCommunity,'chooseShopCommunity',_shopCommunity);
                vc.emit($props.emitLoadData,'listShopCommunityData',{
                    shopCommunityId:_shopCommunity.shopCommunityId
                });
                $('#chooseShopCommunityModel').modal('hide');
            },
            queryShopCommunitys:function(){
                $that._loadAllShopCommunityInfo(1,10,$that.chooseShopCommunityInfo._currentShopCommunityName);
            },
            _refreshChooseShopCommunityInfo:function(){
                $that.chooseShopCommunityInfo._currentShopCommunityName = "";
            }
        }

    });
})(window.vc);
